﻿// Decompiled with JetBrains decompiler
// Type: MCM.Implementation.FluentSettingsPropertyDiscoverer
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using HarmonyLib.BUTR.Extensions;
using MCM.Abstractions;
using MCM.Abstractions.Base;
using MCM.Abstractions.Properties;
using MCM.Abstractions.Wrapper;
using System;
using System.Collections.Generic;
using System.Linq;

#nullable enable
namespace MCM.Implementation
{
  internal sealed class FluentSettingsPropertyDiscoverer : 
    IFluentSettingsPropertyDiscoverer,
    ISettingsPropertyDiscoverer
  {
    private static readonly FluentSettingsPropertyDiscoverer.GetSettingPropertyGroupsDelegate? _getSettingPropertyGroups = AccessTools2.GetPropertyGetterDelegate<FluentSettingsPropertyDiscoverer.GetSettingPropertyGroupsDelegate>("MCM.Abstractions.Base.IFluentSettings:SettingPropertyGroups");

    public IEnumerable<string> DiscoveryTypes { get; } = (IEnumerable<string>) new string[1]
    {
      "fluent"
    };

    public IEnumerable<ISettingsPropertyDefinition> GetProperties(BaseSettings settings)
    {
      FluentSettingsPropertyDiscoverer.GetSettingPropertyGroupsDelegate settingPropertyGroups = FluentSettingsPropertyDiscoverer._getSettingPropertyGroups;
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated field
      return ((settingPropertyGroups != null ? settingPropertyGroups((object) settings).Select<SettingsPropertyGroupDefinition, SettingsPropertyGroupDefinitionWrapper>((Func<SettingsPropertyGroupDefinition, SettingsPropertyGroupDefinitionWrapper>) (x => new SettingsPropertyGroupDefinitionWrapper((object) x))).Cast<SettingsPropertyGroupDefinition>().ToList<SettingsPropertyGroupDefinition>() : (List<SettingsPropertyGroupDefinition>) null) ?? new List<SettingsPropertyGroupDefinition>()).SelectMany<SettingsPropertyGroupDefinition, ISettingsPropertyDefinition>(FluentSettingsPropertyDiscoverer.\u003C\u003EO.\u003C0\u003E__GetAllSettingPropertyDefinitions ?? (FluentSettingsPropertyDiscoverer.\u003C\u003EO.\u003C0\u003E__GetAllSettingPropertyDefinitions = new Func<SettingsPropertyGroupDefinition, IEnumerable<ISettingsPropertyDefinition>>(SettingsUtils.GetAllSettingPropertyDefinitions)));
    }

    private delegate List<SettingsPropertyGroupDefinition> GetSettingPropertyGroupsDelegate(
      object instance);
  }
}
